All Questions
9 questions
2votes
2answers
406views
Should mocks used in unit tests represent entireties or subsets?
I was working on a unit test that has a mock object looking something like: public class TestMock { static { Doodad a = new Doodad(0); Doodad b = new Doodad(1); Doodad c = ...
0votes
1answer
2kviews
Java: Splitting a large unit test class
The project (Java/Spring) I currently work on has a rather large unit-test class for one of its services : more than 1000 lines, several Nested class (one per big functionality), some tests without a ...
-1votes
3answers
1kviews
Should methods with business logic be made private? [duplicate]
So I am writing a project using Spring Boot. All of my logic resides in @Service classes. I have separated each service class based on entity. For example - If I have two independent entities A and B, ...
0votes
2answers
387views
Design Java Testing class for hierarchical objects
Consider the following POJO structure in my main code. I want to create some testing framework for this kind of hierarchical classes, where the calling test method can specify if they want to modify a ...
1vote
2answers
2kviews
What are the drawbacks of modeling (unit) test fixtures in JSON instead of using ObjectFactories?
When writing java tests for an application, be they unit tests or testing a broader scope, the java community tends to model fixtures in terms of object factories that produce fixtures of a defined ...
3votes
2answers
390views
Better To Call In Dive Into Submethods Or Pass Around a result
I have a service that does fairly complicated business logic when it receives a request. I have most the functionality isolated into private methods which dive a couple levels down from the method ...
5votes
5answers
11kviews
Is it feasible and useful to auto-generate some code of unit tests?
Earlier today I have come up with an idea, based upon a particular real use case, which I would want to have checked for feasability and usefulness. This question will feature a fair chunk of Java ...
5votes
3answers
2kviews
Inheritance vs containment while extending a large legacy project
I have got a legacy Java project with a lot of code. The code uses MVC pattern and is well structured and well written. It also has a lot of unit tests and it is still actively maintained (bug fixing, ...
1vote
1answer
5kviews
Is it worth writing a unit test for a DTO with the most basic getter/setters? [duplicate]
The advantage is it protects your DTO against future "enhancements" ?